//===============================================================================
// Microsoft patterns & practices
// Web Client Software Factory
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;
using WCSFContrib.ECommerceCatalog.User;
using WCSFContrib.ECommerceCatalog.User.Tests.Fakes;
using WCSFContrib.ECommerceCatalog.BusinessEntities;

namespace WCSFContrib.ECommerceCatalog.User.Tests.Mocks
{
    public class MockUserController : IUserController
    {
        public bool GetUserProfileCalled = false;
        public bool GetProductCalled = false;
        public bool StartUserPageFlowCalled = false;
        public bool GetCartByUserNameCalled = false;
        public bool GoCheckoutPageCalled = false;
        public bool RemoveItemFromCartCalled = false;
        public bool CreateUserProfileCalled = false;
        public bool GetOrdersByUserNameCalled = false;
        public bool AddAddressCalled = false;
        public bool AddPaymentMethodCalled = false;
        public bool UpdateAddressCalled = false;
        public bool UpdatePaymentCalled = false;
        public bool RemoveAddressCalled = false;
        public bool RemovePaymentMethodCalled = false;
        public bool CurrentPageCalled = false;

        private FakeUsersProfilesService fakeUsersProfilesService;
        private FakeItemsService fakeItemsService;
        private FakeCartService fakeCartService;
        private FakeOrdersService fakeOrdersService;

        public MockUserController()
        {
            fakeUsersProfilesService = new FakeUsersProfilesService();
            fakeItemsService = new FakeItemsService();
            fakeCartService = new FakeCartService();
            fakeOrdersService = new FakeOrdersService();
        }

        #region IUserController Members

        public void StartUserPageFlow()
        {
            StartUserPageFlowCalled = true;
        }

        public Cart GetCartByUserName(string userName)
        {
            GetCartByUserNameCalled = true;
            return fakeCartService.GetCartByUserName(userName);
        }

        public ICollection<Order> GetOrdersByUserName(string userName)
        {
            GetOrdersByUserNameCalled = true;

            return fakeOrdersService.GetOrdersByUserName(userName);
        }

        public Item GetProduct(int productId)
        {
            GetProductCalled = true;
            return fakeItemsService.GetItemById(productId);
        }

        public void RemoveItemFromCart(string userName, int productId, int quantity)
        {
            RemoveItemFromCartCalled = true;

            Item item = fakeItemsService.GetItemById(productId);
            fakeCartService.RemoveItem(userName, item, quantity);
        }

        public void OrderCheckout(string userName, DateTime orderDate, BusinessEntities.Address billingAddress, BusinessEntities.Address shippingAddress, BusinessEntities.Payment paymentMethod)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public void GoCheckoutPage()
        {
            GoCheckoutPageCalled = true;
        }

        public UserProfile GetUserProfile(string userName)
        {
            GetUserProfileCalled = true;

            return fakeUsersProfilesService.GetUserProfileByUserName(userName);
        }

        public void AddAddress(int userProfileId, BusinessEntities.Address address)
        {
            AddAddressCalled = true;
        }

        public void AddPaymentMethod(int userProfileId, BusinessEntities.Payment payment)
        {
            AddPaymentMethodCalled = true;
        }

        public void RemoveAddress(int userProfileId, int addressId)
        {
            RemoveAddressCalled = true;
        }

        public void RemovePaymentMethod(int userProfileId, int paymentId)
        {
            RemovePaymentMethodCalled = true;
        }

        public void CreateUserProfile(string userName)
        {
            CreateUserProfileCalled = true;
        }

        public void UpdateAddress(int userProfileId, Address address)
        {
            UpdateAddressCalled = true;
        }

        public void UpdatePayment(int userProfileId, Payment payment)
        {
            UpdatePaymentCalled = true;
        }

        public Address GetAddresById(int addressId)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public Payment GetPaymentById(int paymentId)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public void ClearErrors()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public void GoUserProfilePage()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public void GoCartPage()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public string CurrentPage
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
            set
            {
                CurrentPageCalled = true;
            }
        }

        #endregion
    }
}
